<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');
// --------------------------------------------------------------------
/**
 * 用户注册接口Sx_reg
 *
 * 本接口实现用户注册
 * 接口只判断用户名，密码，邮件地址是否为空
 *用户名，邮件地址是否存在
 *
 * @author		冯超
 * @copyright	Copyright (c) 2011 世讯网络
 * @link		http://www.hellophp.net
 * @since		Version 1.0
 * @filesource
 */
// --------------------------------------------------------------------

class Sx_reg extends CI_Controller {
	//用户名
	var $UserName;
	//密码
	var $UserPwd;
	//邮件地址
	var $UserEmail;
	//手机
	var $UserMobi;
	//key
	var $UserMobikey;
	//是否为POST提交
	var $UserPostTrue = FALSE;
	//提交数据验证
	var $UserDataY = TRUE;
	//注册类型
	var $jointype;
	//外部系统类型
	var $systype;
	//外部授权码
	var $appid;
	//接入设备类型
	var $divtype;
	//机器码
	var $mcode;
	//城市
	var $city;

	public function index() {
		$this -> UserName = $this -> input -> post("User_name");
		$this -> UserPwd = $this -> input -> post("User_pass");		
		$this -> UserEmail = $this -> input -> post("User_mail");
		$this -> UserMobi = $this -> input -> post("Mcode");
		$this -> UserMobikey = $this -> UserName ."||".$this -> UserName ."||" . time() . "||sxhck";
		if ($this -> UserName == "" || $this -> UserPwd == "" || $this -> UserEmail == "") {
			$this -> UserDataY = FALSE;
		}
		$this -> city = $this -> input -> post('City');
		if (!$this -> sx_db_mod -> checkuser($this -> UserName) || !$this -> sx_db_mod -> checkuser($this -> UserEmail)) {
			print($this -> fengchaoclass -> showhckmsg("", "", $this -> lang -> line('hck_reg_usercheck'), TRUE));
		} else {			
			$this -> getPost();
		}
	}

	/*
	 * 执行提交
	 */

	public function getPost() {

		//如果提交数据验证通过
		if ($this -> UserDataY == TRUE) {
			$pwd = trim($this -> input -> post("User_pass"));	
			$this->UserPwd = $this->passwordhash->Hashpassword($pwd) ;
			$dbArr = array('user_login' => $this -> UserName, 'user_pass' => $this -> UserPwd, 'user_nicename' => $this -> UserName, 'user_email' => $this -> UserEmail, 'user_mobi' => $this -> UserMobi, 'user_city' => $this -> city, 'user_registered' => date("Y-m-d H:i:s"), 'user_mobi_key' => $this -> fengchaoencode -> url_base64_encode($this -> UserMobikey));

			print($this -> sx_db_mod -> sx_reg($dbArr));

		} else {
			print($this -> fengchaoclass -> showhckmsg("", "", $this -> lang -> line('hck_reg_no'), TRUE));
			exit ;
		}
	}

}
